#!/usr/bin/env node
import inquirer from "inquirer";
import chalk from "chalk";
import ora from "ora";

async function main() {
    console.log(chalk.blue.bold("🚀 欢迎使用 NB CLI"));

    // 问题 1：选择环境
    const { env } = await inquirer.prompt([
        {
            type: "list",
            name: "env",
            message: "请选择构建环境:",
            choices: ["feature", "uat", "beta", "prod"]
        }
    ]);

    // loading 动画
    const spinner = ora(`正在构建 ${env} 环境...`).start();
    await new Promise(r => setTimeout(r, 2000));
    spinner.succeed(`构建完成: ${chalk.green(env)}`);

    // 问题 2：多选
    const { apps } = await inquirer.prompt([
        {
            type: "checkbox",
            name: "apps",
            message: "请选择要构建的应用:",
            choices: ["app1", "app2", "app3", "app4"]
        }
    ]);

    console.log(chalk.yellow("你选择了:"), apps.join(", "));
}

main();
